package com.zmn.oms.dubbo.impl.zmn.master.member;

import org.apache.dubbo.config.annotation.Service;
import com.zmn.common.dto2.ResponseDTO;
import com.zmn.common.utils.reflect.BeanMapper;
import com.zmn.oms.common.exception.OmsBaseException;
import com.zmn.oms.dubbo.dto.common.work.BaseRequestDIO;
import com.zmn.oms.dubbo.dto.common.work.MasterVerifyMemberOrderDIO;
import com.zmn.oms.dubbo.dto.common.work.MemberReviewDRO;
import com.zmn.oms.dubbo.dto.common.work.ProcMemberReviewDIO;
import com.zmn.oms.dubbo.impl.OmsBaseRemoteService;
import com.zmn.oms.dubbo.interfaces.zmn.master.member.MasterMemberWorkRemoteService;
import com.zmn.oms.dubbo.utils.DubboConsts;
import com.zmn.oms.model.dto.work.masterwork.MasterVerifyMemberOrderDTO;
import com.zmn.oms.model.dto.work.masterwork.MemberReviewDTO;
import com.zmn.oms.model.dto.work.masterwork.ProcMemberReviewDTO;
import com.zmn.oms.zmn.business.interfaces.work.masterwork.ZsMasterWorkBService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 类描述：工程师处理会员单
 *
 * @author heciqi
 * @date 2020/03/27 13:46
 */
@Slf4j
@Service(loadbalance = "roundrobin", timeout = 5000, retries = 2, version = DubboConsts.INTERFACE_VERSION, validation = "false")
public class MasterMemberWorkRemoteServiceImpl extends OmsBaseRemoteService implements MasterMemberWorkRemoteService {
	//private static final String TAG = "会员工单-工程师-dubbo接口";

	@Autowired
	private ZsMasterWorkBService zsMasterWorkBService;
	/**
	 * 查询会员单审核
	 *
	 * @param getMemberReviewDIO
	 */
	@Override
	public ResponseDTO<MemberReviewDRO> getMemberReview(BaseRequestDIO getMemberReviewDIO) {
		try {
			MemberReviewDTO memberReviewDTO = zsMasterWorkBService.getMemberReview(getMemberReviewDIO.getPlat(), getMemberReviewDIO.getOrderId(),
					getMemberReviewDIO.getWorkId(), getMemberReviewDIO.getMasterId());

			MemberReviewDRO memberReviewDRO = BeanMapper.map(memberReviewDTO, MemberReviewDRO.class);
			return ResponseDTO.success(memberReviewDRO);
		} catch (OmsBaseException e) {
			return ResponseDTO.fail(e.getCode(), e.getMessage());
		}
	}

	/**
	 * 审核会员单
	 *
	 * @param procMemberReviewDIO
	 */
	@Override
	public ResponseDTO procMemberReview(ProcMemberReviewDIO procMemberReviewDIO) {
		ProcMemberReviewDTO procMemberReviewDTO = BeanMapper.map(procMemberReviewDIO, ProcMemberReviewDTO.class);
		super.setLogParam(procMemberReviewDIO, procMemberReviewDTO);

		return ResponseDTO.success();
	}

	/**
	 * @Description 查询会员单审核信息(重写)
	 * @Author xiaofei
	 * @Param BaseRequestDIO
	 * @Return ResponseDTO<MemberReviewDRO>
	 * @Version 1.0
	 * @Date 2020-06-11 12:00
	 */
	@Override
	public ResponseDTO<MemberReviewDRO> getMemberVerifyInfo(BaseRequestDIO getMemberReviewDIO) {
		try {
			MemberReviewDTO memberReviewDTO = zsMasterWorkBService.getMemberVerifyInfo(getMemberReviewDIO.getPlat(), getMemberReviewDIO.getOrderId(),
					getMemberReviewDIO.getWorkId(), getMemberReviewDIO.getMasterId());

			MemberReviewDRO memberReviewDRO = BeanMapper.map(memberReviewDTO, MemberReviewDRO.class);
			return ResponseDTO.success(memberReviewDRO);
		} catch (OmsBaseException e) {
			return ResponseDTO.fail(e.getCode(), e.getMessage());
		}
	}

	/**
	 * @Description (师傅)审核会员单(重写)
	 * @Author xiaofei
	 * @Param MasterVerifyMemberOrderDIO
	 * @Return ResponseDTO
	 * @Version 1.0
	 * @Date 2020-06-11 12:02
	 */
	@Override
	public ResponseDTO masterVerifyMemberOrder(MasterVerifyMemberOrderDIO masterVerifyMemberOrderDIO) {
		try {

			MasterVerifyMemberOrderDTO verifyMemberOrderDTO = BeanMapper.map(masterVerifyMemberOrderDIO, MasterVerifyMemberOrderDTO.class);
			super.setLogParam(masterVerifyMemberOrderDIO, verifyMemberOrderDTO);

			zsMasterWorkBService.masterVerifyMemberOrder(verifyMemberOrderDTO);
			return ResponseDTO.success();
		} catch (OmsBaseException e) {
			return ResponseDTO.fail(e.getCode(), e.getMessage());
		}
	}

}
